package com.dmall.vue.controller;

import com.dmall.vue.domain.User;
import com.dmall.vue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Mr.Wang
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public List<User> list() {
        List<User> list = userService.findAll();
        return list;
    }

    @GetMapping("/findOne")
    public User findOne(Integer id) {
        return userService.findOne(id);
    }

    @PostMapping("/update")
    public String update(@RequestBody User user) {
        userService.update(user);
        return "success";
    }
}
